<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>点我</button>
    <input type="text" />
    <script>
      //dom对象
      const ipt = document.querySelector("input");
      ipt.addEventListener("blur", (e) => {
        console.log("  失焦----->  ", e.target.value);
      });
      const btn = document.querySelector("button");
      btn.addEventListener("mouseenter", (e) => {
        ipt.value = "focus";
      });
      //回车事件keyup 表示按住之后鼠标不松手
      ipt.addEventListener("keyup", (e) => {
        if (e.key === "Enter") {
          alert("用户按了回车键", e.target.value);
        }
      });
    </script>
  </body>
</html>
